@extends('admin.layout.main')
@section('content')
<section class="content-header">
  <h1>
    角色分配
  </h1>
  <ol class="breadcrumb">
    <li><a href="javascript:void(0)"><i class="fa fa-dashboard"></i> 权限管理</a></li>
    <li class="active"><a href="/admin/users">用户管理</a></li>
    <li class="active">角色分配</li>
  </ol>
</section>
    <!-- Main content -->
    <section class="content">
        <!-- Small boxes (Stat box) -->
        <div class="row">
            <div class="col-lg-12 col-xs-6">
                <div class="box">
                    <!-- /.box-header -->
                    <div class="box-body">
                        <form action="/admin/users/role/{{$user->id}}" method="POST">
                            {{csrf_field()}}
                            <div class="form-group">
                                    @foreach($roles as $role)
                                        <div class="checkbox">
                                            <label>
                                                <input type="checkbox" name="roles[]" 
                                                    @if($myRoles->contains($role))
                                                     checked 
                                                    @endif
                                                value="{{$role->id}}">
                                                {{$role->name}} - {{$role->description}} 
                                            </label>
                                        </div>
                                    @endforeach
                            </div>
                            <div class="box-footer">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!-- /.content -->
@endsection        